<?php
session_start();
error_reporting(E_ERROR);

include "connect.php";

$productID = $_POST['productID'];

mysql_query("DELETE FROM products WHERE productID = $productID");

$_SESSION['updateMessage'] = "Product: ".$productID." Has Been Deleted"; 

//Remove the images from the server for this product

 $ftp_server="ftp.24-7saddles.com";
 $ftp_user_name="z247s504";
 $ftp_user_pass="PxLpCd07";

 // set up basic connection
 $conn_id = ftp_connect($ftp_server);

 // login with username and password
 $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
 
// change directory to public_html
ftp_chdir($conn_id, 'public_html/images/saddles');

ftp_delete($conn_id, $productID.'_1.jpg');

ftp_delete($conn_id, $productID.'_2.jpg');

ftp_delete($conn_id, $productID.'_3.jpg');

ftp_delete($conn_id, $productID.'_4.jpg');


// close the connection
ftp_close($conn_id);

header("Location: products.php");

?>